package collection;

import java.util.ArrayList;
import java.util.List;

public class ListDemo1 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println(list);

        String str = list.get(2);
        System.out.println(str);

        for (int i=0;i<list.size();i++){
            str = list.get(i);
            System.out.println(str);
        }

        System.out.println(list);
        String old = list.set(2,"six");
        System.out.println(list);
        System.out.println(old);

        for (int i=0;i<list.size()/2;i++){
            String s = list.get(i);
            s = list.set(list.size()-1-i,s);
            list.set(i,s);
        }
    }
}
